﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;
namespace DA1
{
    public partial class Search_SoLuong_ConLaiTrongKho : Form
    {
        public Search_SoLuong_ConLaiTrongKho()
        {
            InitializeComponent();
        }

        private void Search_SoLuong_ConLaiTrongKho_Load(object sender, EventArgs e)
        {
        //Load len cmb
            cmb_LoaiSP.TabStop = true;
            Search_BUS Search_bus = new Search_BUS();
            cmb_LoaiSP.DataSource = Search_bus.GetCmdXe();
            cmb_LoaiSP.DisplayMember = "TenLoai1";
            cmb_LoaiSP.ValueMember = "MaLoai";
            cmb_LoaiNL.DataSource = Search_bus.GetCmdLoaiNL();
            cmb_LoaiNL.DisplayMember = "TenLoai3";
            cmb_LoaiNL.ValueMember = "MaLoai";
        }
        private void btn_Search_Click(object sender, EventArgs e)
        {
            Search_BUS Search_bus = new Search_BUS();
            if(label_LoaiNL.Visible == true)
                DGV_Search_Loai_TenHang.DataSource = Search_bus.GetBtnSearchNL(int.Parse(cmb_LoaiNL.SelectedValue.ToString()),int.Parse(cmb_LoaiSP.SelectedValue.ToString()));
            if (label_LoaiNL.Visible == false)
                DGV_Search_Loai_TenHang.DataSource = Search_bus.GetBtnSearchTP(int.Parse(cmb_LoaiSP.SelectedValue.ToString()));
        }

        private void btn_TimSP_Click(object sender, EventArgs e)
        {
            cmb_LoaiNL.Visible = false;
            label_LoaiNL.Visible = false;
            cmb_LoaiSP.Visible = true;
        }

        private void btn_TimNLG_Click(object sender, EventArgs e)
        {
            cmb_LoaiNL.Visible = true;
            cmb_LoaiSP.Visible = true;
        }

        private void btn_Thoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void btn_Xem_Click(object sender, EventArgs e)
        {
            try
            {
                Search_BUS bus = new Search_BUS();
                DGV_XemTheoSoLuong.DataSource = bus.GetBtnXemTheoSL(int.Parse(txt_SoLuong.Text.ToString()));
            }
            catch
            {
                MessageBox.Show("Chưa nhập dữ liệu hợp lệ ");
            }
        }
    }
}
